<?php	echo $this->Html->script(array('ckeditor/ckeditor','ckfinder/ckfinder'));?>
<?php echo $html->css('jquery.datepick'); ?>
<?php echo $javascript->link('jquery.datepick', true); ?>
<script type="text/javascript">
$(function() {
	$('.popupDatepicker').datepick();
	});
</script>
<script language="javascript" type="text/javascript">
/*<![CDATA[*/
	$(function(){
		$("#lnkSave").click(function(){
			$('#adminForm').submit();
		});

		$("#lnkClose").click(function(){
			window.location = '<?php echo DOMAIN?>/offinvoices';
		});

		$("#adminForm").validate({
			rules: {
				txtName: "required",
			},
			messages: {
				txtName: "Bạn chưa nhập tên bài viết!",
			}
		});
	});
/*]]>*/

	function Checkvalue(ElementId){
		var checkBox = document.getElementById(ElementId);
		if(checkBox.checked==true)
			checkBox.value=1; 
		else checkBox.value=0; 
	}
</script>

<script language="javascript" type="text/javascript">

function Checkvalue(ElementId){
	var checkBox = document.getElementById(ElementId);
	if(checkBox.checked==true)
		checkBox.value=1; 
	else checkBox.value=0; 
}

var error = true;

$(document).ready(function(){
 $("#user").change(function(){
		var user=$("#user").val();
		//alert (user);
		$.ajax({
			type: "GET", 
			url: "<?php echo DOMAIN;?>"+'/offinvoices/ck_user/',
			data: 'user='+user,
			success: function(msg){	
				//alert (msg);	
				$('#user_ck').find('span').remove().end();										
				$('#user_ck').append(msg);					
			}
		});			
	});	
   // ma hoa don invoice_code
   $("#invoice_code").change(function(){
		var invoiceCode=$("#invoice_code").val();
		//alert (invoiceCode);
		$.ajax({
			type: "GET", 
			url: "<?php echo DOMAIN;?>"+'/offinvoices/ck_code/',
			data: 'invoiceCode='+invoiceCode,
			success: function(msg){	
				//alert (msg);	
				$('#code_ck').find('span').remove().end();										
				$('#code_ck').append(msg);					
			}
		});			
	});	
});				

</script>
<style>
.error-message{
	color:#F00;
	margin:10px 20px;
}
</style>
<div id="content-box">
	<div class="border">
		<div class="padding">
			<div id="toolbar-box">
   			<div class="t"><div class="t"><div class="t"></div></div></div>
			<div class="m">
				<div class="toolbar" id="toolbar">
				<table class="toolbar">
				<tr>
					<td class="button" id="toolbar-save">
					<a href="javascript:;//Cập nhật" id="lnkSave" class="toolbar">
						<span class="icon-32-save" title="Cập nhật"></span>
						Cập nhật
					</a>
					</td>
					<td class="button" id="toolbar-cancel">
					<a href="javascript:;//Đóng" id="lnkClose" class="toolbar">
						<span class="icon-32-cancel" title="Đóng"></span>
						Đóng
					</a>
					</td>
				</tr>
				</table>
				</div>
				<div class="header icon-48-langmanager">Tạo hóa đơn offline</div>
				<div class="clr"></div>
			</div>
			<div class="b"><div class="b"><div class="b"></div></div></div>
			</div>
			<div class="clr"></div>
			<div id="element-box">
				<div class="t"><div class="t"><div class="t"></div></div></div>
				<div class="m">
				<form action="<?php echo DOMAIN?>/offinvoices/edit" method="post" name="adminForm" enctype="multipart/form-data" id="adminForm" autocomplete="off">
					<div class="col width-60">
						<fieldset class="adminform">
						<legend>Thông tin chi tiết</legend>
						<table class="admintable" cellspacing="1">
						<tr>
							<td width="150" class="key">
								<label for="txtName">Mã hóa đơn  <span style="color:#F00">(*)</span></label>
							</td>
							<td>
								<?php echo $this->Form->input('Invoice.code',array('label'=>'','readonly'=>'readonly','id'=>'invoice_code','class'=>'inputbox','style'=>'float:left; margin-right:5px;')); ?>
                                <?php echo $this->Form->input('Invoice.id'); ?>
                                	<div id="code_ck"><span id="error"></span></div>
							</td>
						</tr>
						<tr>
							<td width="150" class="key">
								<label for="txtName">ID nhà phân phối <span style="color:#F00">(*)</span></label>
							</td>
							<td>
								<?php echo $this->Form->input('Invoice.id_user',array('label'=>'','id'=>'user','value'=>$nameMember,'class'=>'inputbox','style'=>'float:left; margin-right:5px;')); ?>
                            	<div id="user_ck"><span id="error"></span></div>
                            </td>
								
                        </tr>
                        <tr>
							<td width="150" class="key">
								<label for="txtName">Diễn giải   </label>
							</td>
							<td> 
								 <?php  echo $this->Form->input('Invoice.interpretation', array('cols'=>60, 'rows'=>10, 'type'=>'textarea','label'=>'','id'=>'txtMetaDescription','style'=>'margin-left:10px;'));?> 
							</td>
						</tr>
                        <tr>
							<td width="150" class="key">
								<label for="txtName">Tổng số tiền  <span style="color:#F00">(*)</span></label>
							</td>
							<td>
								<?php echo $this->Form->input('Invoice.total_money',array('label'=>'','id'=>'txtName','class'=>'inputbox', 'onkeypress'=>'return keypress(event);')); ?>
							</td>
						</tr>
                         <tr>
							<td width="150" class="key">
								<label for="txtName">Ngày viết hóa đơn</label>
							</td>
							<td>
								<?php echo $this->Form->input('Invoice.day',array('label'=>'','value'=>$this->data['Invoice']['invoice_date'],'id'=>'txtName','class'=>'popupDatepicker','style'=>'width:218px;height:20px;')); ?>
							</td>
						</tr>
                      
						
						</table>
						</fieldset>
					</div>
					<div class="col width-40">
						<fieldset class="adminform">
						<legend>Mở rộng</legend>
						<table cellspacing="1" class="admintable">
						<tbody>
						<tr>
							<td class="key">
								<label for="chekActive">Trạng thái</label>
							</td>
							<td>
								 <?php	echo $this->Form->input('Invoice.status',array('type'=>'checkbox','label'=>false)); ?>
								<label id="lbActive">Hoạt động</label>
							</td>
						</tr>
						
					
						
						
						
						</tbody></table>
						</fieldset>
						
					</div>
					<div class="clr"></div>
					<input type="hidden" name="hndId" id="hndId" value="" />
				</form>
				<div class="clr"></div>
				</div>
				<div class="b"><div class="b"><div class="b"></div></div></div>
			</div>
			<noscript>Warning! JavaScript must be enabled for proper operation of the Administrator back-end.</noscript>
			<div class="clr"></div>
		</div>
		<div class="clr"></div>
	</div>
</div>
